package me.zhengjie.modules.system.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.system.domain.req.HomeDetailReq;
import me.zhengjie.modules.system.domain.resp.HomeDetailResp;
import me.zhengjie.modules.system.domain.resp.OrderRevenueResp;
import me.zhengjie.modules.system.service.AdminCommonService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 通用Controller
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "后管通用接口")
@RequestMapping("/api/admin/common")
@Slf4j
public class AdminCommonController {

    private final AdminCommonService adminCommonService;

    @PostMapping("/home")
    @Log("主页详情")
    @ApiOperation("主页详情")
    public ResponseEntity<Object> home(@RequestBody HomeDetailReq req){
        log.info("/api/admin/common/home  后管收益:{}",req);
        HomeDetailResp resp = adminCommonService.home(req);
        return new ResponseEntity<>(resp, HttpStatus.OK);
    }

    @PostMapping("/timePeriod")
    @Log("按时间段筛选展示收益结果")
    @ApiOperation("按时间段筛选展示收益结果")
    public ResponseEntity<List<OrderRevenueResp>> timePeriod(@RequestBody HomeDetailReq req){
        log.info("/api/admin/common/timePeriod  后管收益:{}",req);
        return new ResponseEntity<>(adminCommonService.timePeriod(req), HttpStatus.OK);
    }

}
